module hang(
	input dieKey,
	input rstKey,
	input guess,
	output [7:0]hangman,
	input rst2);
	
	parameter [7:0] NOBODY = 8'b000000;
	reg [7:0] wrong;
	reg[7:0] die;	
	
	
	always @(posedge dieKey or negedge rstKey or posedge rst2)
	begin
		if (rstKey == 0 || rst2 == 1'b1)
		begin
			wrong <= NOBODY;
			die <= NOBODY;
		end
			
		else
		begin
				if(dieKey == 1) // if the player guess=1 add a body part
				begin
					wrong <= wrong + 1;
					if(wrong <= 7)
					begin
					case(wrong)
						8'd1: die <= 7'b0000001;
						8'd2: die <= 7'b0000011;
						8'd3: die <= 7'b0000111;
						8'd4: die <= 7'b0001111;
						8'd5: die <= 7'b0011111;
						8'd6: die <= 7'b0111111;
						8'd7: die <= 7'b1111111;
					endcase
					end
					else
						begin
						wrong <= NOBODY;
						die <= NOBODY;
						end
					end
				end
	end
	assign hangman = die;
	endmodule

			
	
	